package com.bawei.room;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/15 09:08
 * @Description : Student
 */
//1:创建实体类--》表
@Entity(tableName = "student")
public class Student {
    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id",typeAffinity = ColumnInfo.INTEGER)
    private long id;
    @ColumnInfo(name = "username",typeAffinity = ColumnInfo.TEXT)
    private String username;
    @ColumnInfo(name = "age",typeAffinity = ColumnInfo.INTEGER)
    private int age;
    //V 2.0:新添加sex字段
//    @ColumnInfo(name = "sex",typeAffinity = ColumnInfo.INTEGER)
//    private int sex;
    //V3 3.0:将sex字段修改为text类型
    @ColumnInfo(name = "sex",typeAffinity = ColumnInfo.TEXT)
    private String sex;

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

//    public Student(long id, String username, int age, int sex) {
//        this.id = id;
//        this.username = username;
//        this.age = age;
//        this.sex = sex;
//    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", age=" + age +
                '}';
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student(long id, String username, int age) {
        this.id = id;
        this.username = username;
        this.age = age;
    }
}
